#pragma once
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>

#include "interrupt.h"

#define configUSE_DEBUG 1 // enable debug function
#define configUSE_ASSERT 1 // enable assert function
#define configUSE_MAllOC 1 // enable usb malloc function

#define BeeGetTick() SYS_GetTick()  // get tick function
#define configMAX_DELAY (0xFFFFFFFF) // max delay time

#if (configUSE_MAllOC == 1)
    #define BeeMalloc(size) malloc(size)
    #define BeeFree(ptr) free(ptr)
#else
    #define BeeMalloc(size)
    #define BeeFree(ptr)
#endif

#define retTRUE (0)
#define retFALSE (-1)
#define retERROR (-2)
#define retTIMEOUT (-3)
#define retBLOCKED (-4)
#define retEMPTY (-5)
#define retFULL (-6)
#define retBUSY (-7)
#define retNO_MATCH (-8)

#if (configUSE_DEBUG == 1)
    #include <stdio.h>
    #define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
    #define debug(fmt, ...)
#endif

#if defined ( __GNUC__ )
    #define __weak __attribute__((weak))
#endif

#if (configUSE_ASSERT == 1)
    #include <stdio.h>
    #define __DISABLE_IRQ()  // __asm volatile ("cpsid i")
    #define checkACCESS(x) if(!(x)){ printf( "\nAssertion failed in %s:%d\n", __FILE__, __LINE__ ); __DISABLE_IRQ(); for(;;);}
#else
    #define checkACCESS(x)
#endif

